<?php 
/**
 * 客户应付款统计
 * @copyright   Copyright (c) 2006 - 2010 DZH 友拓软件友拓通
 * @category   	账目信息
 * @package  	Action
 * @author    	李恺弘
 * @version 	2.1,2012-07-22
 */

class ClientStatPublicAction extends CommonAction {
	
	 function _initialize(){
	 	addLang('stat');
	 	parent::_initialize();
	 }
	///查看列表
	public function index() { 
			$this->statFundDate();	///统计日期的显示公式	
	   ///获取当前Action名称
	 	$name = $this->getActionName(); 
			///获取当前模型
		$model 	= D($name);     
		///格式化+获取列表信息  
		$list	=	$model->getIndex(); 
		///assign
		$this->assign('list',$list);
	///			echo '<pre>';print_r($list);
		///display
		$this->displayIndex(); 
	}
    	 
    	///查看明细
    	public function view() {     
	       ///获取当前Action名称
		 	$name = $this->getActionName(); 
	 		///获取当前模型
			$model 	= D($name);     
			$client_id	=	$_GET['client_id']?$_GET['client_id']:$_GET['comp_id'];
			$this->assign('link1',U('/ClientStat/view/type/1/currency_id/'.$_GET['currency_id'].'/comp_id/'.$client_id.'/basic_id/'.$_GET['basic_id'].''));
			$this->assign('link2',U('/ClientStat/view/type/2/currency_id/'.$_GET['currency_id'].'/comp_id/'.$client_id.'/basic_id/'.$_GET['basic_id'].''));
			$this->assign('link3',U('/ClientStat/view/type/3/currency_id/'.$_GET['currency_id'].'/comp_id/'.$client_id.'/basic_id/'.$_GET['basic_id'].''));  
			///格式化+获取列表信息  
			$list	=	$model->getDetail();  
			///assign
			$this->assign('list',$list); 
			$dd_clictn = S('client');
			$this->client_name = $dd_clictn[$client_id]['client_name']; 
			///display 
			$this->display('view');
    	}
    	
    	
    ///统计日期的显示公式
	public function statFundDate(){ 
		if ($_POST['date']['from_paid_date']){ 
			if (empty($_POST['date']['to_paid_date'])){
				$_POST['date']['to_paid_date']	=	date('Y-m-d');	
			} 
			$_POST['paid_date']				=	$_POST['date']['to_paid_date'];
		}elseif ($_POST['date']['to_paid_date'] && empty($_POST['date']['from_paid_date'])){
			$_POST['paid_date']	=	$_POST['date']['lt_paid_date']	=	$_POST['date']['to_paid_date'];
			unset($_POST['date']['to_paid_date']);
		}
	}
	
}